<#include "license.ftl">
<@license/>
package ${doc.all.package}.gwt.mvp;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;
import redora.client.mvp.*;
import redora.configuration.rdo.gwt.model.*;
import redora.configuration.rdo.gwt.mvp.view.*;
import ${doc.all.package}.gwt.model.*;

public class AppActivityMapper implements ActivityMapper {

    private ClientFactory clientFactory;

    public AppActivityMapper(ClientFactory clientFactory) {
        super();
        this.clientFactory = clientFactory;
    }

    @Override
    public Activity getActivity(Place place) {
        if (place instanceof BrowsePlace) {
<#assign elseThing = "">
<#list doc["/all/object"] as model>
            ${elseThing}if ("${model.@name?lower_case}".equals(((redora.client.mvp.Place)place).name)) {
                return new BrowseActivity<${model.@name}>(${model.@name}.class, clientFactory);
    <#assign elseThing = "} else ">
</#list>
            } else if ("redoratrash".equals(((redora.client.mvp.Place)place).name)) {
                return new BrowseActivity<RedoraTrash>(RedoraTrash.class, clientFactory);
            } else if ("redoraconfiguration".equals(((redora.client.mvp.Place)place).name)) {
                return new BrowseActivity<RedoraConfiguration>(RedoraConfiguration.class, clientFactory);
            }
        } else if (place instanceof EditPlace) {
<#assign elseThing = "">
<#list doc["/all/object"] as model>
            ${elseThing}if ("${model.@name?lower_case}".equals(((redora.client.mvp.Place)place).name)) {
                return new EditActivity<${model.@name}>(${model.@name}.class, clientFactory);
    <#assign elseThing = "} else ">
</#list>
            } else if ("redoratrash".equals(((redora.client.mvp.Place)place).name)) {
                return new EditActivity<RedoraTrash>(RedoraTrash.class, clientFactory);
            } else if ("redoraconfiguration".equals(((redora.client.mvp.Place)place).name)) {
                return new EditActivity<RedoraConfiguration>(RedoraConfiguration.class, clientFactory);
            }
        }
        return null;
    }
}